#!/sbin/openrc-run

VPN=${SVCNAME#*.}
if [ ${SVCNAME} != "quicktun" ]; then
  pidfile="/var/run/quicktun.${VPN}.pid"
else
  pidfile="/var/run/quicktun.pid"
fi

command=/usr/bin/quicktun

start() {
  if [ -e "/etc/quicktun/${VPN}.conf" ]
  then
    source "/etc/quicktun/${VPN}.conf"
  else
    eerror "Config /etc/quicktun/${VPN}.conf not found"
    exit 1
  fi

  ebegin "Starting ${SVCNAME}"
  start-stop-daemon --start --exec ${command} --pidfile ${pidfile} \
    --background --make-pidfile
  eend $?
}
